using GooglePlayGames;
using UnityEngine;

public class LeaderboardController : MonoBehaviour
{
	public static int checkSignIn;

	private static LeaderboardController instance;

	public string leaderboardMission;

	public string leaderboardMaps;

	public string leaderboardVehicle;

	public string leaderboardDoubleCoins;

	public string leaderboardBestScore;

	public string leaderboardTotalCoins;

	public static LeaderboardController Instance => instance;

	private void Awake()
	{
		if (instance == null)
		{
			instance = this;
			Object.DontDestroyOnLoad(base.gameObject);
		}
		else if (instance != this)
		{
			UnityEngine.Object.Destroy(base.gameObject);
		}
	}

	private void Start()
	{
		leaderboardMission = "CgkI6uKr0IMDEAIQAg";
		leaderboardMaps = "CgkI6uKr0IMDEAIQAQ";
		leaderboardVehicle = "CgkI6uKr0IMDEAIQAw";
		leaderboardDoubleCoins = "CgkI6uKr0IMDEAIQAA";
		leaderboardBestScore = "CgkI6uKr0IMDEAIQBA";
		leaderboardTotalCoins = "CgkI6uKr0IMDEAIQBQ";
		PlayGamesPlatform.Activate();
		LogIn();
	}

	public void LogIn()
	{
		Social.localUser.Authenticate(delegate(bool success)
		{
			if (success)
			{
				OnAddScoreToLeaderBorad();
				checkSignIn = 1;
			}
			else
			{
				checkSignIn = 0;
			}
		});
	}

	public void ShowLeaderBoard_Android()
	{
		OnAddMissionToLeaderBorad();
		OnAddMapToLeaderBorad();
		OnAddVehicleToLeaderBorad();
		OnAddDoubleCoinsToLeaderBorad();
		OnAddScoreToLeaderBorad();
		OnAddTotalCoinsToLeaderBorad();
		Social.ShowLeaderboardUI();
		UnityEngine.Debug.Log("ShowLB_Android");
	}

	public void OnAddMissionToLeaderBorad()
	{
		if (Social.localUser.authenticated)
		{
			Social.ReportScore(DataManager.Instance.Missions, leaderboardMission, delegate
			{
			});
		}
	}

	public void OnAddMapToLeaderBorad()
	{
		if (Social.localUser.authenticated)
		{
			Social.ReportScore(DataManager.Instance.Maps, leaderboardMaps, delegate
			{
			});
		}
	}

	public void OnAddVehicleToLeaderBorad()
	{
		if (Social.localUser.authenticated)
		{
			Social.ReportScore(DataManager.Instance.Vehicle, leaderboardVehicle, delegate
			{
			});
		}
	}

	public void OnAddDoubleCoinsToLeaderBorad()
	{
		if (Social.localUser.authenticated)
		{
			Social.ReportScore(DataManager.Instance.X2Coins, leaderboardDoubleCoins, delegate
			{
			});
		}
	}

	public void OnAddScoreToLeaderBorad()
	{
		if (Social.localUser.authenticated)
		{
			Social.ReportScore(PlayerPrefs.GetInt(BadLogic.nameMap + "BESTSCORE"), leaderboardBestScore, delegate
			{
			});
		}
	}

	public void OnAddTotalCoinsToLeaderBorad()
	{
		if (Social.localUser.authenticated)
		{
			Social.ReportScore(PlayerPrefs.GetInt("COIN"), leaderboardTotalCoins, delegate
			{
			});
		}
	}

	public void OnLogOut()
	{
		((PlayGamesPlatform)Social.Active).SignOut();
	}

	public void ShowLeaderBoard()
	{
		Object.FindObjectOfType<SoundMusicManager>().TapIAP();
		ShowLeaderBoard_Android();
	}
}
